#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   mysql.py    
@Contact :   raogx.vip@hotmail.com
@License :   (C)Copyright 2017-2018, Liugroup-NLPR-CASIA

@Modify Time      @Author    @Version    @Desciption
------------      -------    --------    -----------
2023/8/27 14:39   caijiahao      1.0         Bytedancer
'''

# import lib
import pymysql as pmq

con = pmq.connect(host='localhost',
                  user='root',
                  password='123456',
                  database='',  # 添加自己数据库
                  port=3306,
                  charset='utf8mb4',
                  cursorclass=pmq.cursors.DictCursor)

cur = con.cursor()


def insert(data):
    sql = "INSERT INTO t_field_type(" \
          "fvarchar," \
          "fbigint," \
          "fbigint_unsigned," \
          "fbinary," \
          "fbit," \
          "fblob," \
          "fbool_tinyint," \
          "fchar," \
          "fdate," \
          "fdatetime," \
          "fdecimal," \
          "fdouble," \
          "fdouble_precision," \
          "fenum," \
          "ffloat," \
          "fint," \
          "fint_unsigned," \
          "finteger," \
          "finteger_unsigned," \
          "flong_varbinary_mediumblob," \
          "flong_varchar_mediumtext," \
          "flongblob," \
          "flongtext," \
          "fmediumblob," \
          "fmediumint," \
          "fmediumint_unsigned," \
          "fmediumtext," \
          "fnumeric_decimal," \
          "freal_double," \
          "fset," \
          "fsmallint," \
          "fsmallint_unsigned," \
          "ftext," \
          "ftime," \
          "ftimestamp," \
          "ftinyblob," \
          "ftinyint," \
          "ftinyint_unsigned," \
          "ftinytext," \
          "fvarbinary," \
          "fyear," \
          "fjson) VALUES('" + \
          str(data[0]) + "','" + \
          str(data[1]) + "','" + \
          str(data[2]) + "','" + \
          str(data[3]) + "','" + \
          str(data[4]) + "','" + \
          str(data[5]) + "','" + \
          str(data[6]) + "','" + \
          str(data[7]) + "','" + \
          str(data[8]) + "','" + \
          str(data[9]) + "','" + \
          str(data[10]) + "','" + \
          str(data[11]) + "','" + \
          str(data[12]) + "','" + \
          str(data[13]) + "','" + \
          str(data[14]) + "','" + \
          str(data[15]) + "','" + \
          str(data[16]) + "','" + \
          str(data[17]) + "','" + \
          str(data[18]) + "','" + \
          str(data[19]) + "','" + \
          str(data[20]) + "','" + \
          str(data[21]) + "','" + \
          str(data[22]) + "','" + \
          str(data[23]) + "','" + \
          str(data[24]) + "','" + \
          str(data[25]) + "','" + \
          str(data[26]) + "','" + \
          str(data[27]) + "','" + \
          str(data[28]) + "','" + \
          str(data[29]) + "','" + \
          str(data[30]) + "','" + \
          str(data[31]) + "','" + \
          str(data[32]) + "','" + \
          str(data[33]) + "','" + \
          str(data[34]) + "','" + \
          str(data[35]) + "','" + \
          str(data[36]) + "','" + \
          str(data[37]) + "','" + \
          str(data[38]) + "','" + \
          str(data[39]) + "','" + \
          str(data[40]) + "','" + \
          str(data[41]) + \
          "')"

    print(sql)
    cur.execute(sql)  # ignore_security_alert
    # 提交到数据库执行
    con.commit()
